<?php

class System{
	
	private $url;
	private $explode;
	private $controller;
	private $action;
	private $params;
	
	public function __construct(){
		$this->setURL();
		$this->setExplode();
		$this->setController();
		$this->setAction();
		$this->setParams();
	}
	
	private function setURL(){
		$_GET['url'] = (isset($_GET['url'])) ? $_GET['url'] : 'index/index_action';
		$this->url = $_GET['url'];
	}
	
	private function setExplode(){
		$this->explode = explode('/', $this->url);
	}
	
	private function setController(){
		$this->controller = $this->explode[0];	
	}
	
	private function setAction(){
		$this->action = (!isset($this->explode[1]) || $this->explode[1] == null || $this->explode[1] == 'index'? 'index_action' :$this->explode[1] );
	}
	
	private function setParams(){
		unset($this->explode[0], $this->explode[1]);
		
		if(end($this->explode) == null){
			array_pop($this->explode);
		}
		
		$i = 0;
		if (!empty($this->explode)) {
			foreach ($this->explode as $val){
				if($i % 2 == 0){
					$ind[] = $val;
				}else{
					$value[] = $val;
				}
				$i++;
				echo $val.'<br />';
			}
		}else{
			$ind[] = null;
			$value[] = null;
		}
	}
}